/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.address;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class MailtoURIImpl extends URIBase {
    private String user;
    private String host;

    private static final MailtoURIParser parser = new MailtoURIParser();

    public MailtoURIImpl() {
        super("mailto");
    }


    public MailtoURIImpl(String user, String host) {
        super("mailto");
        this.user = user;
        this.host = host;
    }

    public Object clone() {
        final MailtoURIImpl uri = new MailtoURIImpl();
        uri.cloneInternals(this);
        if (parsed) {
            uri.user = this.user;
            uri.host = this.host;
        }
        return uri;
    }

    protected URIParser getParser() {
        return parser;
    }

    protected String buildStringValue() {
        return getScheme() + ':' + user + '@' + host;
    }

    public String getUser() {
        parse();
        return user;
    }

    public void setUser(String user) {
        parse();
        this.user = user;
        invalidateStringValue();
    }

    public String getHost() {
        parse();
        return host;
    }

    public void setHost(String host) {
        parse();
        this.host = host;
        invalidateStringValue();
    }

    /**
     * This method determines if this is a URI with a scheme of "sip" or "sips".
     *
     * @return true if the scheme is "sip" or "sips", false otherwise.
     */
    public boolean isSipURI() {
        return false;
    }

    protected static MailtoURIImpl createLazily(byte[] data, int start, int end) {
        final MailtoURIImpl uri = new MailtoURIImpl();
        uri.data = data;
        uri.start = start;
        uri.end = end;
        uri.parsed = false;
        return uri;
    }
}
/*
 * $Log$
 */